const app = getApp()
const {mockData} = require('../mockData.js');
const Chart = require('./chart/chart.js');
const rpx2px = (rpx) => { return rpx / 750 * app.globalData.sysInfo.screenWidth };

Page({
	data: {
		cw: 0,
		ch: 0,
		ctx: null,
		chart: null,
		myCarthData: [],
		myChartConfig: {}
	},

	// 启动绘制
	startDraw (config) {
		let data = mockData();
		this.setData({
			myCarthData: data
		})
	},

	onUpdate () {
		this.setData({
			myCarthData: mockData()
		})
	},

	onChooseViewData (e) {
		console.log(e.detail);
	},

	onReady () {
		this.startDraw();
		// let ctx = wx.createCanvasContext('chart', this);
		// let query = wx.createSelectorQuery();
		// let ele = query.select('#myChart_wrapper');
		// ele.boundingClientRect((res) => {
		// 	this.setData({
		// 		cw: res.width,
		// 		ch: res.height,
		// 		ctx
		// 	}, () => {
		// 		this.startDraw();
		// 	})
		// });
		// query.exec();
	}
})
